Function Editor
The Function Editor is the area for writing, editing and viewing FML expressions. It consists of three parts: a toolbar that provides editing options, the textbox where the expression is edited, and the variable properties.
Use the textbox to write the expression of the variable. The expression can include simple numerical values (any series of digits), variable names (between double quotes), alphanumeric strings (between single quotes), Booleans (true and false) and FML Operators.
- Writing the first characters of a function activates the autocompletion option, which offers the list of existing functions matching the text typed so far. Use the mouse or the up/down and Enter keys to select.
- Similarly, writing the first characters of a variable name (with double quotes) offers the list of existing variables that match the text typed so far.
- In those tools that work with PetroVR Plan results (that is, PetroVR Econ and Contracts) you can also refer to results from Plan in the form "Results: ...".
- When entering a constant, you can specify a unit between square brackets, e.g. 40 [day]. Constants for which a unit has not been specified will be interpreted by PetroVR according to their context; see below.
- To know the base unit of variables referenced in the expression, click anywhere on the text of the variable to place the cursor, and then click in the same spot again; a tooltip text will display the unit type and the unit.
- If an expression contains a ratio between two quantities with the same unit, this is not automatically resolved as a dimensionless quantity but with a compound unit keeping the two original units.
- A variable of the Text type can reference variables of all other types (numeric, date or Boolean), and retrieves the value as a string (e.g. "12", "true"). Variables of any other type reading a value of a different type yield an Undefined value.
The following buttons grant access to a hierarchy of variables (both input and runtime), depending on the tool currently in use. Double-click or drag-and-drop variables to include them in the expression. Inactive variables (not used in the current model) are displayed in red. These will yield indefinite values if included in FML expressions.
- Plan variables.
- PetroVR Portfolio variables.
- PetroVR Econ variables.
- Globals variables.
- Contracts variables.
The following commands are also available:
- Variables can also be drag-and-dropped from the Variable editing area directly into the textbox:
- The button opens a numeric pad for entering numbers and operators.
- The button gives access to the hierarchy of existing FML Functions. Double-click or drag-and-drop functions to include them in the expression.
- The button runs the FML Expression Simplifier.
- Use the button to toggle between displaying the expression in the standard format and in TeX format. When the latter is enabled, PetroVR translates the expression into the Unicode Nearly Plain Text Encoding of Mathematics, a syntax specially designed to render high quality mathematical formulas, inspired in TeX. Then it renders it in a TeX-like output using the TOM2 interface to RichEdit controls. This visualization is specially suited for fractions, exponents, subindexes, parentheses, Greek letters, numbers, radicals, and other mathematical symbols and notations. In this view, long variable names are displayed in shortened (though non-conflicting) forms. The formula cannot be edited when in TeX mode, but you can still select and display the definition of the variables included and browse for other expressions referring to them.
When you modify an expression by adding or replacing text in the Function Editor, the and icons appears in the upper right corner of the window. Use the icon to apply the changes, or to cancel them, without exiting the Editor. You can also press the Ok button to apply the changes and close the window. At this moment your changes are subject to a twofold validation:
- Syntax and spelling: The system checks the spelling of function names, use of brackets, etc. You will not be able to save your changes until all issues of this kind are addressed.
- Consistency: The system checks that a valid value can be obtained from the function. Consistency issues include references to non existent variables, wrong or missing arguments in functions, etc. A warning message is issued for each problem of this kind. In this case you can still apply your changes but the calculation will be displayed as "Undefined". Unresolved consistency issues may affect the simulation and/or its results.
Also, when validating the expression or closing the Function Editor all constants for which a unit has not been defined between square brackets are given one according to context. In order to do this, PetroVR performs a dimensional analysis of the expression in its current state trying to deduce the unit type of each constant, and then assigning to it the base unit defined for that unit type (see Unit Setup).
FML functions use the Windows predefined list separator to separate arguments. Regional setting inconsistencies may cause conflict if identical characters are selected as separators. See Recommended Regional Settings.
Note also that the list of variables available when the Function Editor is invoked from Catalogs are only those belonging to the type of object specific to the catalog, not those of the project as a whole. Some special variables are also offered when opening the Editor from the catalog, even if they cannot be edited in the catalog itself; this is the case with Fluid Deliverability (Facilities Catalog), Oil Component Percent, Gas Initial Oil Yield and Gas Initial Water Yield (Fluid Catalog).